package com.hezi.umeng;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.RadioGroup;

import com.hezi.umeng.fragment.HomeFragment;
import com.hezi.umeng.utils.NavFooterUtils;
import com.hezi.umeng.utils.ToastUtils;
import com.umeng.message.IUmengRegisterCallback;
import com.umeng.message.PushAgent;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA;

public class MainActivity extends BaseActivity implements NavFooterUtils.OnCheckedChangeListener {
    private ShareAction mShareAction;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setTitle("Share");
        initView();
    }

    private void initView() {
        Fragment[] fragments = new Fragment[]{HomeFragment.newInstance()
                , HomeFragment.newInstance()
                , HomeFragment.newInstance()
                , HomeFragment.newInstance()};
        NavFooterUtils.init(this, fragments, 0);
        NavFooterUtils.setOnCheckedChangeListener(this);
        mShareAction = new ShareAction(this)
                .withTitle("Hello")
                .setDisplayList(SHARE_MEDIA.QQ, SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QZONE);
        setOnFabClickListener(new OnFabClickListener() {
            @Override
            public void onFabClick(View v) {
                mShareAction.open();
            }
        });
        setFabVisibility(View.GONE);

    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        int i = group.indexOfChild(findViewById(checkedId));
        switch (i) {
            case 0:
                setTitle("home");
                break;
            case 1:
                setTitle("Classify");
                break;
            case 2:
                setTitle("com");
                break;
            case 3:
                setTitle("mine");
                break;
        }
    }
}
